package com.sphd.beautysalon.presenter;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.model.UserHomeModelImpl;
import com.sphd.beautysalon.view.UserHomeView;
import com.sphd.beautysalon.info.RestaurantInfo;

import java.util.List;

/**
 * Created by Hu on 2016/11/02
 */

public class UserHomePresenterImpl implements UserHomePresenter {
    private UserHomeModelImpl userHomeModel;
    private UserHomeView userHomeView;

    public UserHomePresenterImpl(UserHomeView userHomeView) {
        this.userHomeView = userHomeView;
        userHomeModel = new UserHomeModelImpl();
    }

    @Override
    public void addData(String url) {
        userHomeView.showLoading();
        userHomeModel.senUrl(url, this);
    }

    @Override
    public void sendError(VolleyError error) {
        userHomeView.dissLoading();
    }

    @Override
    public void sendRes(List<RestaurantInfo> restaurantInfos, int resNo) {
        userHomeView.sendRes(restaurantInfos, resNo);
        userHomeView.dissLoading();
    }

    @Override
    public void getMoney(String s) {
        userHomeModel.sendMoneyUrl(s, this);
    }

    @Override
    public void sendMoney(double sumtopup, double account, double daytopup, double sumorder, double dayorder) {
        userHomeView.sendMoney(sumtopup, account, daytopup, sumorder, dayorder);
    }

    @Override
    public void getResList(String s) {
        userHomeView.showLoading();
        userHomeModel.sendResUrl(s, this);
    }

    @Override
    public void sendFundingRes(List<RestaurantInfo> restaurantInfos) {
        userHomeView.receiveRes(restaurantInfos);
    }

    @Override
    public void addRestaurant(String s) {
        userHomeView.showLoading();
        userHomeModel.addRest(s, this);
    }

    @Override
    public void recRes(int res) {
        userHomeView.recRes(res);
        userHomeView.dissLoading();
    }
}